function newFrame = removeConnComp(frame, minimumConnectedComponentSize)
    % Removes any connected component whose size
    % is less than minimumConnectedComponentSize
    newFrame = frame;
    minimum = 1;
    while minimum < minimumConnectedComponentSize
        connectedComponent = bwconncomp(newFrame);
        numOfPixels = cellfun(@numel, connectedComponent.PixelIdxList);
        minimum = min(numOfPixels);
        [~,indexOfMin] = min(numOfPixels);
        newFrame(connectedComponent.PixelIdxList{indexOfMin}) = 0;
    end
end

